-
Notifications
You must be signed in to change notification settings - Fork 273
docs: create document describing act function and related errors #969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good article when it comes to technicals and knowledge, I find it to be detailed and explanatory, but not overwhelming.
I went also through examples by trying them locally 👍
All of my remarks are cosmetic and/or readability concerns - free to merge once covered.
|
||
When wrapping rendering call with `act` we see that the changes caused by `useEffect` hook have been applied as we would expect. | ||
|
||
### When to use act |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having a hard time understanding why this is only in "sync" section. How is it when it comes to "async"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great explanation!
website/docs/UnderstandingAct.md
Outdated
test('render with real timers - sleep', async () => { | ||
const view = render(<TestAsyncComponent />); | ||
await act(async () => { | ||
await sleep(50 + 10); // Wait a bit longer then setTimeout in component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a bit confusing because said component (and initial use of the value 50
) is higher in this document and as a reader I'd rather not have to scroll up
Summary
Our users frequently report cryptic errors related to
act()
function usage, like #379 or #859. In order to address this I've created Understanding Act function document to describe it's why and how to use it. Consider it to be initial version of the document describing theact
basics, with intention to add more specific information for async act warnings later on.Please share your thoughts and suggestions to improve this document.
Test plan
Docs only
I've run docosaurus and manually verified links and layout.